package com.gomyb.common.page;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * @Copyright (c)</   b> HeC<br/>
 * @createTime 2018/10/29 21:18
 * @Description:
 */
@Setter
@Getter
public class PageResult<T> {

    private Boolean success;

    private Long total = 0L;

    private List<T> rows;

    public PageResult(Boolean success, Long total, List<T> rows) {
        this.success = success;
        this.total = total;
        this.rows = rows;
    }

    public PageResult(Long total, List<T> rows) {
        this.total = total;
        this.rows = rows;
    }

    public PageResult(Boolean success) {
        this.success = success;
    }

    public PageResult(Page<T> page) {
        this.success = true;
        this.total = page.getTotalElements();
        this.rows = page.getContent();
    }

    public PageResult() {
    }
}

